package tianrun.ziguan.api.calculate.config.dto.request.common.add.edit;

import com.google.common.collect.Lists;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class AddOrEditBodyBatch {

    @NotBlank(message = "tableName 不能为空！")
    private String tableName;

    private List<Map<String, Object>> data;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public List<Map<String, Object>> getData() {
        return data;
    }

    public void setData(List<Map<String, Object>> data) {
        this.data = data;
    }
    public List<AddOrEditBody> toList(){
        ArrayList<AddOrEditBody> list = Lists.newArrayList();
        for (Map<String, Object> datum : data) {
            AddOrEditBody addOrEditBody = new AddOrEditBody();
            addOrEditBody.setData(datum);
            addOrEditBody.setTableName(tableName);
            list.add(addOrEditBody);
        }
        return list;

    }
}
